const fs = require("fs");
const defaultJson = require("./defaultLanguageJson.json");

const writeFile = (path, data) => {
  return new Promise((resolve) => {
    fs.writeFile(path, data, (err) => {
      if (err) {
        console.log("err", err);
        return;
      }
      console.log(`${path} 写入成功!`);
      resolve();
    });
  });
};

const targetJson = {};
for (var key in defaultJson) {
  const valueKey = defaultJson[key]["code（资源的唯一标识）"];
  const value = defaultJson[key].中文翻译;
  targetJson[valueKey] = value;
}

writeFile("./target.json", JSON.stringify(targetJson));
